import Vue from "./Vue.js";
import { Dep } from "./Dep.js";
export class Watcher {
    el:HTMLElement
    vm:Vue;
    vmKey:string;
    constructor(vm:Vue,el:HTMLElement,vmKey:string){
        this.el = el
        this.vm = vm
        this.vmKey =  vmKey
        Dep.target = this
        this.update()
        Dep.target = null
        
    }

    update(){
        if(this.el.nodeType === Node.ELEMENT_NODE){
            this.el.innerText = this.vm[this.vmKey]
        } else if (this.el.nodeType === Node.TEXT_NODE){
            this.el.nodeValue = this.vm[this.vmKey]
        }
    }
}